package com.ita.iosa.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.jms.JMSException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ita.iosa.po.Merchant;
import com.ita.iosa.service.AdminManager;
import com.ita.iosa.service.impl.AdminManagerImpl;

/**
 * Servlet implementation class AuditServlet
 */
public class AuditServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private AdminManager adminManager = new AdminManagerImpl();

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public AuditServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		List<Merchant> waitAuditMerchants = new ArrayList<Merchant>();
		waitAuditMerchants = adminManager.showWaitAuditMerchants();
		
		if (!waitAuditMerchants.isEmpty()) {
			request.setAttribute("waitAuditMerchants", waitAuditMerchants);
		}
		request.getRequestDispatcher("/iosa/jsp/admin/audit.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
